package com.china08.yxyapi.repository.mg.attendance;

import java.util.Date;
import java.util.List;

import org.springframework.data.mongodb.repository.MongoRepository;

import com.china08.yxyapi.entity.mg.attendance.YxyTeaAttendance;

/**
 * 每天的打卡记录, 每个教师只要打卡就进行记录
 *
 */

public interface YxyTeaAttendanceRepository extends MongoRepository<YxyTeaAttendance, String> {

    YxyTeaAttendance findTopByDayOfDateAndSchoolId(int dayOfDate, String schoolId);

    List<YxyTeaAttendance> findByDayOfDateAndTeacherIdOrderBySignTime(Integer dayOfDate, String teacherId);

    /** 查询老师打卡 **/
    Integer countByDayOfDateAndTeacherIdAndSchoolId(int parseInt, String teacherId, String schoolId);

    Integer countByDayOfDateAndTeacherId(Integer dayOfDate, String teacherId);

    Integer countByTeacherIdAndSchoolIdAndDayOfDateContaining(String teacherId, String schoolId, Integer dayOfDate);

    /* 最近打卡时间 */
    YxyTeaAttendance findTop1ByTeacherIdAndSchoolIdOrderBySignTimeDesc(String teacherId, String schoolId,
            Date signTime);

    // 今日打卡
    List<YxyTeaAttendance> findByDayOfDateAndTeacherIdAndSchoolId(Integer dayOfDate, String teacherId, String schoolId);

    // 今日打卡次数
    List<YxyTeaAttendance> findByDayOfDateAndTeacherIdAndSchoolIdOrderByCreatedDateDesc(Integer dayOfDate,
            String teacherId, String schoolId);

}
